<#include "/common/_layout.html"/>
<@layout>
<script src="http://apps.bdimg.com/libs/jquery/1.11.1/jquery.min.js" type="text/javascript" ></script>
 <meta charset="utf-8" />
 
 
 <script type="text/javascript">  
		function ajaxupload(id) {
			var form = new FormData(document.getElementById("form"+id));
			$.ajax({
				url : "/upload/file",
				type : "post",
				data : form,
				cache : false,
				processData : false,
				contentType : false,
				success : function(data) {
					if(data==''||typeof(data) == "undefined"||data.indexOf("Exception:") > 0){
						alert("上传失败！"+data);
					}else{
						$.get("/apk/updateurl?filename="+data+"&id="+id,function(data1){
							alert(data1);
							document.getElementById("url"+id).href = "${ProjectName!}"+data1; 
						});
					}
				},
				error : function(e) {
					alert("网络错误，请重试！！");
				}
			});
		}
	</script>  
  
 <title>Apk管理</title>  
<h1>Apk管理&nbsp;&nbsp; <a href="${ProjectName!}/apk/add?">新建apk</a>
	<form action="${ProjectName!}/apk" method="get">
 <input type="text" maxlength="100" autocomplete="on" name="packname" value="com.android.googleplay"/>
 <input type="submit" value="搜索一下" />
</form>

</h1>
<div class="table_box">
	<table class="list">
		<tbody>
			<tr>
				<th width="4%">id</th>
				<th width="12%">apk名称</th>
				<th width="12%">包名</th>
				<th width="4%">版本</th>
				<th width="4%">版本号</th>
				<th width="10%">更新日期</th>
				<th width="10%">编辑</th>
				<th width="12%">更新apk</th>
			</tr>
			
			<#list page.getList() as x>
			<tr>
				<td style="text-align:left;">${x.id}</td>
				<td style="text-align:left;">${x.apkname}</td>
				<td style="text-align:left;">${x.packname}</td>
				<td style="text-align:left;">${x.versionname}</td>
				<td style="text-align:left;">${x.versioncode}</td>
				<td style="text-align:left;">${(x.describe)}<br>(${x.uploaddate})</td>
				<td style="text-align:left;">
					&nbsp;&nbsp;<a href="${ProjectName!}/apk/delete/${x.id}">删除</a>
					&nbsp;&nbsp;<a href="${ProjectName!}/apk/edit/${x.id}">修改</a>
					&nbsp;&nbsp;<a id = "url${x.id}" href="${ProjectName!}${x.url!''}">下载</a>
				</td>
				
				<td style="text-align:left;">
					<form id = "form${x.id}" action="${ProjectName!}/upload/file" enctype="multipart/form-data" method="post">
    					<input type="file" name="file" accept=".apk"/>
    					<input type="button" onclick="ajaxupload(${x.id})" value="上传(<=100M)" /> 
					</form>
				</td>
			</tr>
			</#list>
		</tbody>
	</table>
	<#include "/common/_paginate.html" />
	<@paginate currentPage=page.pageNumber totalPage=page.totalPage actionUrl="/apk/" />
</div>
</@layout>